home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-stoele.adb < prev    next >
Text File  |  1996-01-30  |  3KB  |  69 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --               S Y S T E M . S T O R A G E _ E L E M E N T S              --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.5 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. package body System.Storage_Elements is
  27.  
  28.    --  Address arithmetic
  29.  
  30.    function "+" (Left : Address; Right : Storage_Offset) return Address is
  31.    begin
  32.       return Left + Address (Right);
  33.    end "+";
  34.  
  35.    function "+" (Left : Storage_Offset; Right : Address) return Address is
  36.    begin
  37.       return Address (Left) + Right;
  38.    end "+";
  39.  
  40.    function "-" (Left : Address; Right : Storage_Offset) return Address is
  41.    begin
  42.       return Left - Address (Right);
  43.    end "-";
  44.  
  45.    function "-" (Left, Right : Address) return Storage_Offset is
  46.    begin
  47.       return Storage_Offset (Left) - Storage_Offset (Right);
  48.    end "-";
  49.  
  50.    function "mod" (Left : Address; Right : Storage_Offset)
  51.      return Storage_Offset is
  52.    begin
  53.       return Storage_Offset (Left) mod Right;
  54.    end "mod";
  55.  
  56.    --  Conversion to/from integers
  57.  
  58.    function To_Address (Value : Integer_Address) return Address is
  59.    begin
  60.       return Address (Value);
  61.    end To_Address;
  62.  
  63.    function To_Integer (Value : Address) return Integer_Address is
  64.    begin
  65.       return Integer_Address (Value);
  66.    end To_Integer;
  67.  
  68. end System.Storage_Elements;
  69.